<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => {
    assert_not_equals(window.internals, undefined,
        'This test requires window.internals to access clipboard');

    assert_selection(
        [
            '<div contenteditable>',
                '<div>',
                    '<div>',
                        '^abcdef',
                        '<div style="text-align: center;">',
                            '<table><tr><td>foo</td><td>bar</td></tr></table>',
                            'ghijk|',
                        '</div>',
                    '</div>',
                '</div>',
            '</div>',
        ].join(''),
        selection => {
            selection.document.execCommand('copy');
            selection.document.execCommand('delete');
            selection.document.execCommand('paste');
        },
        [
            '<div contenteditable>',
                'abcdef',
                '<div style="text-align: center;">',
                    '<table><tbody><tr><td>foo</td><td>bar</td></tr></tbody></table>',
                    'ghijk|',
                '</div>',
            '</div>',
        ].join(''));
});
</script>
